package Tests;

import java.util.Iterator;

import system.BlogSystem;
import bean.BlogBean;
import bean.UserBean;
import dao.BlogDAO;
import dao.DAO;
import dao.UserDAO;

public class UserStoryFacade5 {
	private BlogSystem system = BlogSystem.getInstance();	
	private DAO<UserBean> userDAO = UserDAO.getInstance(); 
	private DAO<BlogBean> blogDAO = BlogDAO.getInstance(); 
	
	
	public void cleanPersistence() {
		
		Iterator<UserBean> users = userDAO.list().iterator();
		
		while(users.hasNext()){
			UserBean anotherUser = users.next();
			userDAO.delete(anotherUser);
		}
		
		Iterator<BlogBean> blogs = blogDAO.list().iterator();
		
		while(blogs.hasNext()){
			BlogBean anotherBlog = blogs.next();
			blogDAO.delete(anotherBlog);
		}
		system.finalize();
	
	}
	
	public void createProfile(String login, String senha, String nome_exibicao,
			String email, String sexo, String dataNasc, String endereco, String interesses,
			String quem_sou_eu, String filmes, String musicas, String livros) throws Exception {
		
		system.createUser(login, senha, nome_exibicao, email, sexo, dataNasc, endereco, interesses, quem_sou_eu, filmes, musicas, livros);	
	}
	
	public String logon(String login, String senha) throws Exception{
		return system.login(login, senha);
	
	}
	
	public String createBlog(String sessionID, String title, String description) throws Exception{
		return system.createBlog(sessionID, title, description);
	}
	
	public String getBlogInformation(String blogID, String atributo) throws Exception{
		return system.getInformationBlog(blogID, atributo);
	}
	
	public void logoff(String idSession) throws Exception{
		system.logout(idSession);
	}
	public void saveData(){
		
	}
	
	public void changeBlogInformation(String sessionID, String blogID, String attribute, String value) throws Exception{
		system.changeBlogInformation(sessionID, blogID, attribute, value);
	}

}
